package app.netant.book.geilixsw;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
import app.netant.book.base.BaseEntity;
import app.netant.book.base.BasePage;
import cn.lily.com.enviroment.Enviroment;

public class GeilixswPage extends BasePage {

	public GeilixswPage(String netSite) {
		super(netSite);
		this.tableKey = "geilixsw";
		this.selectKey = "#main .list_center #sitebox dl";
		this.preHref = "http://www.geilixsw.com";
	}

	@Override
	public String buildHref(Element element) {
		Elements parts = element.select("dd.book_yuedu a");
		for(int i=0;i<parts.size();i++){
			String text = parts.get(i).text().trim();
			if("TXT下载".equals(text)){
				String href = parts.get(i).attr("href");
				return href;
			}
		}
		return null;
	}

	@Override
	public BaseEntity buildEntity() {
		return new GeilixswEntity();
	}

	@Override
	public BaseDetail buildDetail(String href) {
		return new GeilixswDetail(href);
	}

	@Override
	public void afterEntity(BaseEntity entity, Element element) {
		
		Elements parts = element.select("dd h3 .uptime");
		if(parts.size()>0){
			String date = parts.get(0).text();
			entity.setNovelDate(date);
		}
		
	}
	
	public static void main(String[] args) {
		Enviroment.createEnv();
		Enviroment.getEnv().getLogBean().beginLog();
		GeilixswPage page = new GeilixswPage("http://www.geilixsw.com/xuanhuan/");
		page.analyseHref();
	}
	
}
